package enums;

import java.util.ArrayList;
import java.util.List;

public enum ActivityCategoryEnum {
    All(0,"所有分类"),
    Study(1,"学习分享"),
    Sport(2,"健身运动"),
    Game(3,"游戏娱乐"),
    Competition(4,"比赛信息"),
    GroupBuy(5,"组团优惠"),
    Else(9,"其它" );
    private  int id;
    private  String name;
    //构造函数
    ActivityCategoryEnum(int id, String name) {
        this.id = id;
        this.name = name;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    //根据id查询类型
    public static ActivityCategoryEnum getById(int id){
        for(ActivityCategoryEnum category : ActivityCategoryEnum.values()){
        if(category.id == id){
            return category;
            }
        }
        return null;
    }
    //返回所有类型
    public static List<ActivityCategoryEnum> getAllCategory(){
        List<ActivityCategoryEnum> categoryEnumList = new ArrayList<>();
        //遍历，将元素添加至集合中
        for (ActivityCategoryEnum category : ActivityCategoryEnum.values()) {
            categoryEnumList.add(category);
        }
        return categoryEnumList;
    }

}
